package main

/*
	1、从键盘接受任意字符串，统计其中数字、大写字母、小写字母的个数
	2、从键盘接受任意字符串，将它反转   abc --》 cba
*/
import (
	"fmt"
	"unicode/utf8"
)

func main() {
	var str1 string
	fmt.Println("请输入随机字符串")
	fmt.Scanln(&str1)
	var count_bigchar int = 0
	var count_smallchar int = 0
	var count_num int = 0
	for _, i := range str1 {
		switch {
		case '0' <= i && i <= '9':
			count_num++
		case 'A' <= i && i <= 'Z':
			count_bigchar++
		case 'a' <= i && i <= 'z':
			count_smallchar++
		}
	}
	fmt.Printf("此字符串的数字有%d个，大写字母有%d个。小写字母有%d个\n", count_num, count_bigchar, count_smallchar)

	var str2 string
	fmt.Println("请输入任意字符串，我将实现对他的反转")
	fmt.Scanln(&str2)
	runes := []rune(str2) // 将字符串转换为rune切片
	for i, j := 0, utf8.RuneCountInString(str2)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	fmt.Println(string(runes))
}
